home *** CD-ROM | disk | FTP | other *** search
- "-----------------------------------------------------------------"
- " Object Class is the Root of all other Classes in AmigaTalk. "
- "-----------------------------------------------------------------"
-
- Class Object "! methods variables !"
- [
- == anObject
- ^ <primitive 7 self anObject >
- |
- ~~ x
- ^ (self == x) not
- |
- = x
- ^ (self == x) "Is the receiver equal to x??"
- |
- ~= x
- ^ (self = x) not "Is the receiver NOT equal to x??"
- |
- asString
- ^ <primitive 152 (self class)> "Avoid recursion!"
-
- "^ self class printString" "<<--Infinite recursive method."
- |
- asSymbol
- ^ self asString asSymbol "Return the class as a Symbol."
- |
- yourself "Synonym for self."
- ^ self
- |
- class
- ^ <primitive 1 self >
- |
- copy
- ^ self shallowCopy
- |
- deepCopy ! size newobj !
- size <- <primitive 4 self>.
-
- (size < 0)
- ifTrue: [^ self] "if special just copy object"
- ifFalse: [ newobj <- self class new.
-
- (1 to: size) do: [:i |
- <primitive 112 newobj i ( <primitive 111 self i > copy ) > ].
- ^ newobj ]
- |
- do: aBlock ! item !
- item <- self first.
-
- ^ [item notNil] whileTrue:
- [aBlock value: item. item <- self next]
- |
- error: aString
- <primitive 122 aString self>
- |
- first
- ^ self
- |
- isKindOf: aClass ! objectClass !
- objectClass <- self class.
-
- [objectClass notNil] whileTrue:
- [(objectClass == aClass) ifTrue: [^ true].
-
- objectClass <- objectClass superClass].
- ^ false
- |
- isMemberOf: aClass
- ^ aClass == self class
- |
- isNil
- ^ false
- |
- next
- ^ nil
- |
- notNil
- ^ true
- |
- print
- <primitive 121 (self printString)>
- |
- printNoReturn
- <primitive 120 (self printString)>
- |
- printString
- ^ self asString
- |
- respondsTo: cmd
- ^ self class respondsTo: cmd
- |
- shallowCopy ! size newobj !
- size <- <primitive 4 self>.
-
- (size < 0)
- ifTrue: [^ self] "if special just copy object"
- ifFalse: [ newobj <- self class new.
-
- (1 to: size) do: [:i |
- <primitive 112 newobj i <primitive 111 self i > > ].
-
- ^ newobj ]
- |
- subclassResponsibility: methodString ! msg !
- msg <- String new: 'Method ',methodString,' should be implemented in a SubClass!'.
- ^ <primitive 181 13 msg 'User ERROR:' 'OKAY'>
- |
- notImplemented: methodString ! msg !
- msg <- String new: 'Method ',methodString,' NOT implemented!'.
- ^ <primitive 181 13 msg 'User ERROR:' 'OKAY'>
- |
- doesNotUnderstand: methodString ! msg !
- msg <- String new: 'Method ',methodString,' NOT understood!'.
- ^ <primitive 181 13 msg 'User ERROR:' 'OKAY'>
- |
- shouldNotImplement: methodString ! msg !
- msg <- String new: 'Method ',methodString,' should NOT BE implemented!'.
- ^ <primitive 181 13 msg 'User ERROR:' 'OKAY'>
- |
- in: object at: index put: value
- "Change data field in object, used during initialization."
- "Returns the intialized object (from LittleSmalltalk V4.0)."
-
- ^ <primitive 112 object index value>
- "
- |
- instanceVariables ! names ! "return all our variable names"
- ((super class) notNil)
- ifTrue: [ names <- (super class) instanceVariables ]
- ifFalse: [ names <- Array new: 0 ].
-
- (variables isNil or: [ variables isEmpty ])
- ifFalse: [ names <- names + variables ].
-
- ^ names
- |
- parseMethod: text ! newparser !
-
- newparser <- Parser new.
-
- ^ ((newparser text: text instanceVars: self instanceVariables)
- parse: self)
- |
- addMethod ! text !
-
- text <- (' ' edit).
- "
- "smalltalk newIO: 'Enter yes or no:' title: 'Compile Method??'.
- ((smalltalk getString) = 'yes')
- ifTrue: [ ^ (self addMethod: text) ]
-
- (self question: 'compile method?')
- ifTrue: [ ^ (self addMethod: text) ]
- "
- "
- ^ (self addMethod: text)
- |
- addMethod: text ! meth !
- meth <- (self parseMethod: text).
-
- (meth notNil)
- ifTrue: [ (methods == nil)
- ifTrue: [ methods <- Dictionary new ].
-
- methods at: (meth name) put: meth.
-
- ^ ('method inserted: ', (meth name) printString)
- ]
- "
- ]
-